<?php
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}

//小学  选择题:每题2分  填空题:答对一个2分  填空题（每题4分，共32分）  判断题：每题2分

$tiKU=json_decode(file_get_contents('xiaoxues.txt'), true);


$sql="SELECT *  FROM `uinfo` WHERE `fen` IS NULL  ORDER BY `id`  LIMIT 0,1";
 
$query=$mysqli->query($sql);
if($query->num_rows>0){
   $getU=$query->fetch_assoc();
   $uid=$getU['uid'];
   $phone=$getU['phone'];
   $updateId=$getU['id'];

   var_dump($getU);

   echo "<br /><br />";
   echo $uid,"........",$phone;
    echo "<br /><br />";
}else{
    exit;
}

$fen=0;
$query=$mysqli->query("SELECT yi,uid,phone FROM `dan` where uid='".$uid."' and phone='".$phone."' limit 0,1 ");
//var_dump($tiKU['xz']);
echo "<br />";
if($query->num_rows>0){

    while ($list=$query->fetch_array()) {

        $yhtj=json_decode($list['yi'], true);
        foreach ($yhtj as $key => $value) {
             
             
             if ($value == $tiKU['xz'][$key]) {
                 $fen++;    
                 echo "$key ... $value";
                 echo "<br />";
             }

        }
     echo "<br />";
     var_dump($list);
     
    }
 
}

echo "<br />";
echo $fen;
echo "<br /><br />";


$sql="update `uinfo` set fen=".$fen." WHERE id='".$updateId."'";
$query=$mysqli->query($sql);
echo $sql;


/**

TRUNCATE danxuan_z;
TRUNCATE danxuan;
TRUNCATE pan_z;
TRUNCATE pan;
TRUNCATE tian_z;
TRUNCATE tian;

*/
?>
<script type="text/javascript">
    window.setTimeout(function(){
         window.location.reload();
    }, 600);

</script>